package top.younote.learn.sort;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @Description:
 * @Author: duanyu
 * @CreateTime: 2020-08-22 20:58
 **/
public class CommonUtils {

    /**
     * 不重复随机数的文件路径
     */
    private static final String DISTINCT_FILEPATH = "./data/distinctSortNums.txt";
    /**
     * 可重复文件路径
     */
    private static final String REPEATABLE_FILEPATH = "./data/repeatableSortNums.txt";

    public static int[] readSortNums() throws IOException {
        List<String> sortNumsStrList = FileUtils.readLines(new File(DISTINCT_FILEPATH), "UTF-8");
        int[] sortNums = new int[sortNumsStrList.size() + 1];
        int i = 0;
        for (String cur : sortNumsStrList) {
            sortNums[i++] = Integer.parseInt(cur);
        }
        return sortNums;
    }
}
